import {_ as e} from "./ContentWrap.vue_vue_type_script_setup_true_lang.6ff9ed7b1729265196717.js";
import {u as a, a as t, _ as l, b as s} from "./useCrudSchemas.2c3b314d1729265196717.js";
import {_ as o} from "./Dialog.vue_vue_type_style_index_0_lang.071fc2701729265196717.js";
import {
    d as r,
    m as n,
    g as i,
    w as m,
    o as u,
    h as d,
    a as p,
    J as c,
    r as f,
    c as _,
    k as v,
    i as h,
    I as g,
    l as y,
    t as w,
    s as b,
    H as I
} from "./index.115af62d1729265196717.js";
import {E as j} from "./el-button.c1876bd01729265196717.js";
import {u as A, F as R, a as P} from "./useForm.9355f9ab1729265196717.js";
import {g as x, d as S, s as k, e as C} from "./system.521d54461729265196717.js";
import {u as F} from "./useValidator.d7fa223e1729265196717.js";
import {c as L} from "./index.eec34c841729265196717.js";
import "./el-divider.111259cd1729265196717.js";
import "./tree.67a6f3e21729265196717.js";
import "./mitt.f0e547641729265196717.js";
import "./el-form-item.eb8d765c1729265196717.js";
import "./_plugin-vue_export-helper.1b428a4d1729265196717.js";

const D = r({
    __name: "Write", props: {currentRow: {type: Object, default: () => null}}, setup(e, {expose: a}) {
        const t = e, {required: l} = F();
        var s;
        n(), L.get({url: "/backend/v1/roles/select", params: s}).then((e => {
            const {setSchema: a} = f;
            a([{field: "role_id", path: "componentProps.options", value: e.data}])
        }));
        const o = i([{
            field: "role_id",
            label: "角色",
            component: "Select",
            formItemProps: {rules: [l()]},
            componentProps: {options: []},
            colProps: {span: 22}
        }, {
            field: "user_name",
            label: "用户名称",
            component: "Input",
            formItemProps: {rules: [l()]},
            colProps: {span: 22}
        }, {
            field: "login_name",
            label: "登录名称",
            component: "Input",
            formItemProps: {rules: [l()]},
            colProps: {span: 22}
        }, {
            field: "password",
            label: "密码",
            component: "Input",
            formItemProps: {rules: [l()]},
            colProps: {span: 22}
        }, {
            field: "avatar",
            label: "头像",
            formItemProps: {rules: [l()]},
            component: "SMUploadThumbnail",
            colProps: {span: 22},
            componentProps: {class: "avatar-uploader", showFileList: !0}
        }]), r = i({user_name: [l()], login_name: [l()], avatar: [l()], password: [l()]}), {
            register: c,
            methods: f,
            elFormRef: _
        } = A({schema: o});
        return m((() => t.currentRow), (e => {
            if (!e) return;
            const {setValues: a, setSchema: t} = f;
            e.password = "", a(e)
        }), {deep: !0, immediate: !0}), a({
            elFormRef: _,
            getFormData: f.getFormData
        }), (e, a) => (u(), d(p(R), {rules: r, onRegister: p(c)}, null, 8, ["rules", "onRegister"]))
    }
}), O = r({
    __name: "Admin", setup(r) {
        const {register: m, tableObject: A, methods: R} = a({
            getListApi: x,
            delListApi: S,
            response: {list: "list", total: "total"}
        }), {getList: F, setSearchParams: L} = R;
        F();
        const {t: O} = n(), V = i([{
            field: "index",
            label: O("sysAdminInfo.index"),
            type: "index",
            form: {show: !1},
            detail: {show: !1}
        }, {field: "user_name", label: O("sysAdminInfo.user_name"), search: {show: !0}}, {
            field: "role_sign",
            label: O("sysAdminInfo.role_sign"),
            table: {show: !1},
            form: {show: !1}
        }, {field: "login_name", label: O("sysAdminInfo.role_sign"), search: {show: !0}}, {
            field: "avatar",
            label: O("sysAdminInfo.avatar"),
            formatter: (e, a, t) => c(P, {
                src: t,
                previewSrcList: [t],
                previewTeleported: !0,
                style: {width: "100px", height: "100px"}
            })
        }, {field: "role_name", label: O("sysAdminInfo.role_name")}, {
            field: "last_login_at",
            label: O("sysAdminInfo.last_login_at")
        }, {field: "created_at", label: O("sysAdminInfo.created_at")}, {
            field: "operate",
            isCustom: !1,
            width: "260px",
            label: O("sysAdminInfo.operate")
        }]), {allSchemas: B} = t(V), U = f(!1), q = f(""), T = () => {
            q.value = O("sysAdminInfo.add"), A.currentRow = null, U.value = !0, E.value = ""
        }, W = f(!1), E = f(""), H = f(), J = f(!1), M = async () => {
            var e;
            const a = p(H);
            await (null == (e = null == a ? void 0 : a.elFormRef) ? void 0 : e.validate((async e => {
                if (e) {
                    J.value = !0;
                    const e = await (null == a ? void 0 : a.getFormData());
                    if ("" === E.value) {
                        await k(e).catch((() => {
                        })).finally((() => {
                            J.value = !1
                        })) && (U.value = !1, A.currentPage = 1, F())
                    } else {
                        await C(e).catch((() => {
                        })).finally((() => {
                            J.value = !1
                        })) && (U.value = !1, F())
                    }
                }
            })))
        };
        return (a, t) => (u(), _(I, null, [v(p(e), null, {
            default: h((() => [v(p(l), {
                schema: p(B).searchSchema,
                onSearch: p(L),
                onReset: p(L),
                onCreated: T
            }, null, 8, ["schema", "onSearch", "onReset"]), v(p(s), {
                tableObject: p(A),
                "onUpdate:tableObject": t[0] || (t[0] = e => g(A) ? A.value = e : null),
                columns: p(B).tableColumns,
                data: p(A).tableList,
                selection: !1,
                align: "center",
                headerAlign: "center",
                pagination: {total: p(A).total},
                onRegister: p(m)
            }, {
                operate: h((({row: e}) => [v(p(j), {
                    type: "primary", plain: "", onClick: a => ((e, a) => {
                        q.value = O("edit" === a ? "sysAdminInfo.editButton" : "sysAdminInfo.detail"), E.value = a, A.currentRow = e, U.value = !0
                    })(e, "edit")
                }, {
                    default: h((() => [y(w(p(O)("sysAdminInfo.editButton")), 1)])),
                    _: 2
                }, 1032, ["onClick"]), v(p(j), {
                    type: "danger", plain: "", onClick: a => (async (e, a) => {
                        var t;
                        A.currentRow = e;
                        const {delList: l, getSelections: s} = R, o = await s();
                        W.value = !0, await l(a ? o.map((e => e.id)) : [null == (t = A.currentRow) ? void 0 : t.id], a).finally((() => {
                            W.value = !1
                        }))
                    })(e, !1)
                }, {default: h((() => [y(w(p(O)("sysAdminInfo.delButton")), 1)])), _: 2}, 1032, ["onClick"])])), _: 1
            }, 8, ["tableObject", "columns", "data", "pagination", "onRegister"])])), _: 1
        }), v(p(o), {
            modelValue: U.value,
            "onUpdate:modelValue": t[2] || (t[2] = e => U.value = e),
            title: q.value
        }, {
            footer: h((() => [v(p(j), {onClick: t[1] || (t[1] = e => U.value = !1)}, {
                default: h((() => [y(w(p(O)("dialogDemo.close")), 1)])),
                _: 1
            }), "detail" !== E.value ? (u(), d(p(j), {
                key: 0,
                type: "primary",
                loading: J.value,
                onClick: M
            }, {default: h((() => [y(w(p(O)("exampleDemo.save")), 1)])), _: 1}, 8, ["loading"])) : b("", !0)])),
            default: h((() => ["detail" !== E.value ? (u(), d(D, {
                key: 0,
                ref_key: "writeRef",
                ref: H,
                "form-schema": p(B).formSchema,
                "current-row": p(A).currentRow
            }, null, 8, ["form-schema", "current-row"])) : b("", !0)])),
            _: 1
        }, 8, ["modelValue", "title"])], 64))
    }
});
export {O as default};
